Skip to content

RBD/NAS: address review comments - #14873

Open
weizhouapache wants to merge 5 commits into
apache:mainfrom
weizhouapache:pr14386-review-fixes
Open

weizhouapache wants to merge 5 commits into
apache:mainfrom
weizhouapache:pr14386-review-fixes

Conversation

@weizhouapache

@weizhouapache weizhouapache commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Description

This PR addresses @abh1sar 's review comments on #14386, which was merged before they were handled.

  • rbd import-diff resizes the image to the size recorded in each diff (do_image_resize in Ceph's Import.cc), so restoring after a volume resize (in place, or createVMFromBackup onto a larger disk) left the image at its backup-time size while the database kept the new one. The restore now resizes the image back to the Volume's size after replaying the diff chain (NAS backup: support incremental backups of RBD volumes #14386 (comment)).
  • Do not fail on an Instance whose last Host has been removed: fall back to a Host in the cluster of the root Volume's pool. A failure while removing the backup anchors no longer fails the caller.
  • Keep the cephx key out of the log of the anchor removal.
  • Always resume an Instance once a suspend was attempted.
  • Undo a killed RBD backup: through an EXIT trap, release the guest, drop the new anchors and unmount the NAS.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  • Unit tests for each fix: NASBackupProviderTest, LibvirtRestoreBackupCommandWrapperTest (new test: the image is resized back to its size after the diffs are applied), LibvirtTakeBackupCommandWrapperTest and the anchor removal wrapper test.
  • Trap logic of nasbackup.sh checked with a stub harness.
  • NAS smoke suite test/integration/smoke/test_backup_recovery_nas.py on a KVM zone with Ceph RBD and NFS primary storage: 12 tests, OK (2 skipped by design).

Not covered: restoring a grown Volume end to end on a real cluster, and killing a backup mid-export on a real host.

How did you try to break this feature and the system with this change?

rbd import-diff resizes the image to the size recorded in each diff, which is the size
the volume had when that backup was taken. A volume grown since then keeps its new size
in the database, so the restored image would be smaller than the volume. Resize the image
back to the size it was recreated with once the chain has been replayed.
getVMHypervisorHost dereferenced the result of hostDao.findById, which is null for a host
which has been removed, so removing an Instance with an RBD volume from its backup offering
failed with a NullPointerException now that it looks up a host to remove the backup anchors.
Fall back to the cluster of the root volume, as for an Instance without a last host.

Removing the anchors is best effort, a later full backup sweeps them, so a runtime failure
there is logged instead of failing the caller.
The disk paths handed to the script are RBDStringBuilder strings, which carry the cephx
key. Log the volume paths instead.
A suspend which timed out can still complete in libvirt after the client was killed, so
the Instance could stay paused with the state file gone. Attempt the resume whenever a
suspend was attempted; only an Instance which is still paused afterwards is an error.
…mount the NAS

The RBD path only trapped TERM/HUP/INT to release the guest, and cleared it once the
snapshots were taken, so a script killed mid-export (agent restart, or a timeout of the
agent) left the NAS mounted with the partial backup and the new anchor behind.

Arm an EXIT trap once the NAS is mounted, as the pull mode path does, and clear it once
the backup is complete. It releases the guest, removes the new anchor and the partial
backup, and unmounts the NAS. The explicit failure paths now exit through the trap. Every
disk a snapshot was attempted on is listed, as a snapshot which timed out can still be
created by Ceph afterwards.
@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@weizhouapache weizhouapache added this to the 24.0 milestone Nov 26, 2026
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.92%. Comparing base (85ca17a) to head (c7b8678).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ce/wrapper/LibvirtRestoreBackupCommandWrapper.java 50.00% 2 Missing and 1 partial ⚠️
...rg/apache/cloudstack/backup/NASBackupProvider.java 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #14873   +/-   ##
=========================================
  Coverage     20.92%   20.92%           
- Complexity    21142    21150    +8     
=========================================
  Files          6057     6057           
  Lines        549556   549565    +9     
  Branches      73477    73481    +4     
=========================================
+ Hits         114991   115012   +21     
+ Misses       421116   421103   -13     
- Partials      13449    13450    +1     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.37% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weizhouapache

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

weizhouapache added a commit to weizhouapache/cloudstack that referenced this pull request Nov 26, 2026
@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20190

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-238)
Environment: kvm-ubuntu26 (x2), zone: Advanced Networking with Mgmt server u26, storage: Ceph (x2)
Total time taken: 66256 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr14873-n238-kvm-ubuntu26.zip
Smoke tests completed. 156 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_uservm_host_control_state Failure 18.25 test_host_control_state.py

@weizhouapache
weizhouapache marked this pull request as ready for review November 27, 2026 09:27
Copilot AI lite review requested due to automatic review settings November 27, 2026 09:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@weizhouapache

Copy link
Copy Markdown
Member Author

this is ready for review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants